$("div.homepage-feature-slides div.cycle-pager span").click(function() {
	var img_block;
	var num;
	for(var i = 0;;i++){
		var img = $("div.homepage-feature-slides a").get(i);
		if(img.style.display == "block" && img.style.visibility != "hidden"){
			num = i-1;
			img_block = img;
			break;
		}
	}
	var spans = $("div.homepage-feature-slides div.cycle-pager span");
	for(var i = 0;;i++){
		if(this == spans.get(i)){
			var img_last = $("div.homepage-feature-slides a").get(i+1);
			img_last.style.display = "block";
			if(i == num)
				break;
			else if(i>num){
				img_last.style.left = "100%";
				$(img_last).animate({left:'0'},"1000","swing");
				$(img_block).animate({left:'-100%'},"1000","swing", function(){
					img_block.style.left = "0";
					img_block.style.display = "none";
					$(spans.get(i)).addClass("cycle-pager-active");
					$(spans.get(num)).removeClass("cycle-pager-active");
				});
				break;
			}
			else if(i<num){
				img_last.style.left = "-100%";
				$(img_last).animate({left:'0'},"1000","swing");
				$(img_block).animate({left:'100%'},"1000","swing", function(){
					img_block.style.left = "0";
					img_block.style.display = "none";
					$(spans.get(i)).addClass("cycle-pager-active");
					$(spans.get(num)).removeClass("cycle-pager-active");
				});
				break;
			}
			
		}
	}
});

setInterval(function(){
	if($("div.homepage-feature-slides div.cycle-pager span.cycle-pager-active").next().length == 0)
		$("div.homepage-feature-slides div.cycle-pager span").first().click();
	else
		$("div.homepage-feature-slides div.cycle-pager span.cycle-pager-active").next().click();
},3000);